#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <ctime>

using namespace std;

typedef long long ll;

int main(){
	ios_base::sync_with_stdio(false);

	int n, m, q;
	while (cin >> n >> m >> q && n) {
		vector<ll> sw;
		vector<string> bl;
		sw.resize(q);
		bl.resize(q);

		ll realst = 0LL;
		for (int i = 0; i < q; i++) {
			ll cursw = 0;
			string s;
			cin >> s >> bl[i];
			ll curch = 0LL;
			for (int sn = 0; sn < n; sn++) {
				if (s[sn] == '1') curch |= (1LL << sn);
			}
			realst ^= curch;
			sw[i] = realst;
		}

		for (int i = 0; i < m; i++) {
			ll ans = (1LL << n) - 1;
			for (int j = 0; j < q; j++) {
				if (bl[j][i] == '1') ans &= sw[j];
				else ans &= ~sw[j];
			}

			int cursw = -1;
			bool ok = true;
			for (int sn = 0; sn < n; sn++) {
				if (ans & (1 << sn)) {
					if (cursw == -1) {
						cursw = sn;
					}
					else {
						ok = false;
						break;
					}
				}
			}

			if (ok) cout << ((cursw > 9) ? char('A' + cursw - 10) : char('0' + cursw));
			else cout << '?';
		}

		cout << endl;
	}
	return 0;
}